package main

import (
	"fmt"
)

func inputData(data chan int)  {
	for i:=1;i<100;i++ {
		data <- i
		fmt.Printf("放入%d\n",i)
	}
	close(data)
}

func outputData(data chan int,isFinish chan bool) {
	for {
		num,ok := <-data
		if !ok {
			break
		}
		fmt.Printf("取出数据%d\n",num)
	}
	isFinish <- true
	close(isFinish)
}

func main()  {
	
	var data chan int
	var isFinish chan bool

	data = make(chan int,10)
	isFinish = make(chan bool, 1)

	go inputData(data)
	go outputData(data,isFinish)

	for {
		if _,ok := <-isFinish; !ok{
			break
		}
	}
}
